package com.econvent.common.log.enums;

import java.util.HashMap;

/**
 * 操作日志-操作类型枚举
 *
 * @author xiekun
 */
public enum ApiOperationType {

    CREATE("CREATE", "新增"),
    SELECT("SELECT", "查询"),
    UPDATE("UPDATE", "修改"),
    DELETE("DELETE", "删除");

    private final String code;
    private final String zhMsg;

    private static HashMap<String, ApiOperationType> API_OPERATION_MAP = new HashMap<>();

    static {
        for (ApiOperationType operationType : ApiOperationType.values()) {
            API_OPERATION_MAP.put(operationType.code, operationType);
        }
    }

    ApiOperationType(String code, String zhMsg) {
        this.code = code;
        this.zhMsg = zhMsg;
    }

    public static ApiOperationType of(String status) {
        if (API_OPERATION_MAP.containsKey(status)) {
            return API_OPERATION_MAP.get(status);
        }
        throw new IllegalArgumentException("invalid api operation type code " + status);
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return zhMsg;
    }
}
